# SPDX-License-Identifier: GPL-2.0-only
#
# Copyright 2025 NXP
#

include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/package.mk

PKG_NAME:=mwifiex-firmware
PKG_RELEASE:=1

MWIFIEX_FM_NAME:=imx-firmware
MWIFIEX_FM_VER:=lf-6.6.52-2.2.0
MWIFIEX_FM_SOURCE:=$(MWIFIEX_FM_NAME)-$(MWIFIEX_FM_VER).tar.bz2
define Download/imx-firmware
  FILE:=$(MWIFIEX_FM_SOURCE)
  PROTO:=git
  URL:=https://github.com/nxp-imx/imx-firmware.git
  VERSION:=lf-6.6.52_2.2.0
  SUBDIR:=mwifiex-firmware
  MIRROR_HASH:=8db2a81e3ecaf88c276cc09916834bc87e56f2b254a112399aecb9ee382f101a
endef
$(eval $(call Download,imx-firmware))

define Package/mwifiex-sdio-imx-firmware
  SECTION:=firmware
  CATEGORY:=Firmware
  TITLE:=NXP mwifiex sdio driver firmware
endef 

define Package/mwifiex-sdio-imx-firmware/install
	$(INSTALL_DIR) $(1)/lib/firmware/mrvl/
	$(CP) \
		$(BUILD_DIR)/mwifiex-firmware/nxp/FwImage_IW416_SD/* \
		$(1)/lib/firmware/mrvl
endef

define Build/Prepare
	$(call Build/Prepare/Default,)
	$(TAR) -C $(BUILD_DIR) -xf $(DL_DIR)/$(MWIFIEX_FM_SOURCE)
endef

define Build/Compile
endef

$(eval $(call BuildPackage,mwifiex-sdio-imx-firmware))
